package com.fbs.wowo.forum.mapper;

import com.fbs.wowo.forum.entity.Reply;
import org.apache.ibatis.jdbc.SQL;

public class ReplySqlProvider {

    public String insertSelective(Reply record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("reply");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=VARCHAR}");
        }
        
        if (record.getCommentId() != null) {
            sql.VALUES("comment_id", "#{commentId,jdbcType=VARCHAR}");
        }
        
        if (record.getReplyId() != null) {
            sql.VALUES("reply_id", "#{replyId,jdbcType=VARCHAR}");
        }
        
        if (record.getReplyTime() != null) {
            sql.VALUES("reply_time", "#{replyTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getFromId() != null) {
            sql.VALUES("from_id", "#{fromId,jdbcType=VARCHAR}");
        }
        
        if (record.getToId() != null) {
            sql.VALUES("to_id", "#{toId,jdbcType=VARCHAR}");
        }
        
        if (record.getStatus() != null) {
            sql.VALUES("status", "#{status,jdbcType=INTEGER}");
        }
        
        if (record.getContent() != null) {
            sql.VALUES("content", "#{content,jdbcType=LONGVARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Reply record) {
        SQL sql = new SQL();
        sql.UPDATE("reply");
        
        if (record.getCommentId() != null) {
            sql.SET("comment_id = #{commentId,jdbcType=VARCHAR}");
        }
        
        if (record.getReplyId() != null) {
            sql.SET("reply_id = #{replyId,jdbcType=VARCHAR}");
        }
        
        if (record.getReplyTime() != null) {
            sql.SET("reply_time = #{replyTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getFromId() != null) {
            sql.SET("from_id = #{fromId,jdbcType=VARCHAR}");
        }
        
        if (record.getToId() != null) {
            sql.SET("to_id = #{toId,jdbcType=VARCHAR}");
        }
        
        if (record.getStatus() != null) {
            sql.SET("status = #{status,jdbcType=INTEGER}");
        }
        
        if (record.getContent() != null) {
            sql.SET("content = #{content,jdbcType=LONGVARCHAR}");
        }
        
        sql.WHERE("id = #{id,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}